<?php session_start(); 
error_reporting(E_ALL);
 ?>
 <html><!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>DrinkDelivery</title>
<!-- InstanceEndEditable -->
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="login">
<img src="image/logo.jpg" width="100" height="30" align="middle">
 <p> <font size="+2" color="#FFFFFF"><a href="CU.html">                                           Contact Us</a></font></p>
<a href="logout.php"><img src="image/logout.png" align="right"></a>
<a href="login.php"><img src="image/login.png" align="right"></a> 
</div>
<div id="header">
<ul>
  <li></li>
<li><a href="store.php"><img src="image/m2.jpg" width="200" height="200"></a></li>
<li><a href="member.php"><img src="image/m3.jpg" width="200" height="200"></a></li>
<li><a href="category.php"><img src="image/m4.jpg" width="200" height="200"></a></li>
</ul>
</div>
<br/>
<div id="content">
<!-- InstanceBeginEditable name="content" -->
<div id="register">
<p>
<h1 align="center">welcome to register your account, thanks for your suporting!</h1>
    <form action="register.php" method="post">  
    <table border="1" cellpadding="10px" cellspacing="0" align="center">
    <tr>
    <th>Name</th>
    <td>
    <input type="text" name="uname" size="40" /> </td>
    </tr>
    <tr>
    <th>Password</th>
    <td>
    <input type="password" name="passwd" size="40" /> </td>
    </tr>
    <tr>
    <th>Password Again</th>
    <td>
    <input type="password" name="passwd2" size="40" /> </td>
    </tr>
    <tr>
    <th>Telephone</th>
    <td>
    <input type="text" name="phone" size="40" /> </td>
    </tr>
    <tr>
    <th>Address</th>
    <td>
    <input type="text" name="addre" size="40" /> </td>
    </tr>
    <th>
    <input type="submit" name="submit" value="Submit" />
    <input type="button" value="Reset"/></th>
    <tr></tr>
    </table>
    </form>    
    <?php
	if ( isset($_REQUEST['submit']) ) 
{
		$connection = mysql_connect("localhost", "root", "");
		if ( !$connection ) {
			die('Could not connect to localhost.');	
							}

		$db = mysql_select_db("test", $connection);
		if ( !$db) {
			die ('Could not find database test.');	
					}
	if (isset($_POST['submit'])) 
		{ 

   if (!$_POST['uname'] | !$_POST['passwd'] |
       !$_POST['passwd2'] | !$_POST['phone']|$_POST['addre'])
			{
        die('You did not fill in a required field.');
    		}
	if($_POST['passwd']!=$_POST['passwd2'])
	{
		die('password are not the same, please try again');
	}
	
	$name_qry="SELECT name FROM users WHERE name =  '".$_POST['uname']."'";
	
	$name_check = mysql_query($name_qry);
	
	$name_checkk = mysql_num_rows($name_check);
	
	if ($name_checkk != 0) {
        die('Sorry, the username: <strong>'.$_POST['uname'].'</strong>'
          . ' is already taken, please pick another one.');
    						}	
		}
	
	$sqlstr = "insert into users (name,password,phone,address) values('" . $_POST['uname'] . "','" . $_POST['passwd'] . "','" . $_POST['phone'] . "','" . $_POST['addre'] . "')";	
	$inst = mysql_query($sqlstr);	
	
	if (!$inst)
 	 {
  		die('Error: ' . mysql_error());
 	 }
	
	mysql_close($connection);	
}
?>
</div>
</p>
<?php mysql_close($connection); ?>
<!-- InstanceEndEditable -->
</div>
<a href="index.php">z</a> </div>
</body>
<!-- InstanceEnd --></html>
